package deepbrain.simnetwork.monitor;

import deepbrain.simnetwork.mechanism.BayesianInferenceMechanism;
import deepbrain.simnetwork.mechanism.Mechanism;
import deepbrain.simnetwork.task.SimulationTask;

public class BayesianInferenceTerminateMonitor extends
		MonitorAdapter<SimulationTask> implements SimTaskMonitor {

	@Override
	public void onStepFinish(SimulationTask task) {
		Mechanism[] bayesianMechanisms = task.getNetwork().getMechanisms();
		for (Mechanism m : bayesianMechanisms) {
			BayesianInferenceMechanism bayesianMechanism = (BayesianInferenceMechanism) m;
			if (!bayesianMechanism.isDetermined())
				return;
		}
		task.stop();
	}

}
